using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Diagnostics;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Ferpect.GameComponents.Design;
using Ferpect.GameState.MenuItems;

namespace Ferpect.GameState.Design
{
    [ToolboxItem(false)]
    public class MenuScreenControl : ViewControl<MenuScreen>
    {
        private ContentManager content;
        private List<System.Drawing.Rectangle> menuItemRects;

        public IList<MenuItem> MenuItems
        {
            get { return this.Component.MenuItems; }
        }

        public MenuItem MenuItemFromPoint(System.Drawing.Point pt)
        {
            return this.Component.MenuItemFromPoint(new Point(pt.X, pt.Y));
        }

        protected override void Initialize()
        {
            EnvDTE.ProjectItem projectItem = this.GetService(typeof(EnvDTE.ProjectItem)) as EnvDTE.ProjectItem;
            if (projectItem != null)
            {
                DesignTimeContentManager designTimeContent = new DesignTimeContentManager(this.Services, projectItem.ContainingProject);
                this.content = designTimeContent;
            }
            DesignTimeScreenManager screenManager = new DesignTimeScreenManager();
            screenManager.Content = this.content;
            screenManager.Initialize();
            this.Component.ScreenManager = screenManager;

            this.menuItemRects = new List<System.Drawing.Rectangle>();
        }

        protected override void Update(GameTime gameTime)
        {
            if (this.Component != null && this.Component.Initialized)
            {
                this.Component.Update(gameTime, false, false);
            }
            base.Update(gameTime);
        }
    }
}
